<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            width: 800px;
            margin: 200px auto;
            color: red;
            text-align: center;
            font: 600 30px/30px "simsun";
        }
    </style>
</head>
   
<body>
    <div></div>
    <script>
    var div=document.getElementsByTagName("div")[0];
       var i=0;
        var text=["当我不再执着的复现往事时","往事才因此成了永恒。","那只萤火虫成了我的记忆","永远的停留在那个黄昏","直到我接受了","“停留”的事实","它就成了我前行的燃料","我已经不再需要去寻找它了"];
        var timer=setInterval(()=>{y()},2000);
         function y() {                     
            div.innerHTML=text[i];
            i++;
            if(i>=text.length)
            {
                i=0;
            }
        }
    </script>
</body>

</html>